package org.wendu.wdoa;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
public class WdoaServiceLeaveApp {
    public static void main(String[] args) {
        SpringApplication.run(WdoaServiceLeaveApp.class,args);
    }
    @Bean
    public WebMvcConfigurer webMvcConfigurer(){

        //配置跨域
        return new WebMvcConfigurer(){
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**")//允许任何地址样式跨域
                        .allowedOriginPatterns("*")//允许UI来源主机为不限
                        .allowedHeaders("*")//允许任何请求头
                        .allowedMethods("GET","POST","PUT","DELETE","OPTIONS")//允许的方法
                        .allowCredentials(true);//允许前端发送session凭证

            }
        };
    }
}
